perf: project imported matches to slim structs in standings import#7654
Open
Rathoz wants to merge 1 commit into
Open
perf: project imported matches to slim structs in standings import#7654Rathoz wants to merge 1 commit into
Rathoz wants to merge 1 commit into
Conversation
1751355 to
29e107e
Compare
hjpalpha
approved these changes
Jun 12, 2026
hjpalpha
left a comment
Collaborator
There was a problem hiding this comment.
seems reasonable on phone
Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
29e107e to
1fc9c87
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR refactors standings match importing to project LPDB match2 records into a slimmer StandingsImportMatch shape at import time, reducing memory usage and avoiding repeated matchFromRecord conversions while keeping tiebreaker behavior unchanged.
Changes:
- Project imported matches into
StandingsImportMatch(only fields consumed by standings/tiebreakers) during LPDB import. - Replace
Table.deepMergeusage inStandingsTable.mergeOpponentsDatawith an allocation-safe merge and a name-keyed fast lookup (withOpponent.samefallback). - Update type annotations so standings/tiebreakers reference
StandingsImportMatchinstead ofMatchGroupUtilMatch.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 2 comments.
| File | Description |
|---|---|
| lua/wikis/commons/Standings/Tiebreaker/Interface.lua | Updates tiebreaker opponent match type to the new slim match struct. |
| lua/wikis/commons/Standings/Table.lua | Removes Table.deepMerge dependency and implements a faster, non-mutating merge for manual/imported opponent data. |
| lua/wikis/commons/Standings/Parse/Lpdb.lua | Introduces StandingsImportMatch and constructs it once per LPDB record before per-round parsing. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
32
to
35
| ---@class StandingTableOpponentData | ||
| ---@field rounds {tiebreakerPoints: number?, specialstatus: string, scoreboard: Scoreboard?, | ||
| ---match: MatchGroupUtilMatch?, matches: MatchGroupUtilMatch[], matchId: string}[]? | ||
| ---match: StandingsImportMatch?, matches: StandingsImportMatch[], matchId: string}[]? | ||
| ---@field opponent standardOpponent |
Comment on lines
136
to
+141
| ---@param roundNumber integer | ||
| ---@param match match2 | ||
| ---@param slimMatch StandingsImportMatch | ||
| ---@param opponents StandingTableOpponentData[] | ||
| ---@param scoreMapper fun(opponent: standardOpponent): number? | ||
| ---@param maxRounds integer | ||
| function StandingsParseLpdb.parseMatch(roundNumber, match, opponents, scoreMapper, maxRounds) | ||
| local match2 = MatchGroupUtil.matchFromRecord(match) | ||
| Array.forEach(match2.opponents, function(opponent) | ||
| function StandingsParseLpdb.parseMatch(roundNumber, slimMatch, opponents, scoreMapper, maxRounds) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
StandingsImportMatchstruct —{matchId, finished, winner, opponents (by ref), slim games}— at import time inParse/Lpdb.lua. Tiebreakers (Buchholz,Game/Util,Game/Rounds/Util) are the only consumers and read exactly these fields. This dropsbracketData,extradata, and full game payloads per match (big memory win on large group stages), andmatchFromRecordnow runs once permatch2record instead of once per(match, round).mergeOpponentsDatainTable.luanow uses a name-keyed opponent index (O(1) fast path, one linear-scan fallback for renamed teams viaOpponent.same) and an explicit allocation-safe merge that reproducesdeepMerge's output without mutating imported structures. TheTablemodule import is removed as it is no longer needed.TiebreakerOpponent.matchesandStandingTableOpponentData.rounds.match/matchesnow referenceStandingsImportMatchinstead ofMatchGroupUtilMatch.How did you test this change?
busted --run=ci: 605 successes / 0 failures / 0 errors (standings_import_spec, standings_table_merge_spec, standings_tiebreaker_spec all pass)luacheckon all three touched files: 0 warnings / 0 errorsstandings-tests-ai(PR test: add integration tests for standings #7647) whose import/merge/tiebreaker specs lock the observable semantics; no test files were modified.🤖 Generated with Claude Code